import 'dart:async';

import 'package:flutter/material.dart';
import 'screens/home_screen.dart';
import 'package:logging/logging.dart';

void main() {
  // 初始化Logger
  Logger.root.level = Level.ALL;
  Logger.root.onRecord.listen((record) {
    debugPrint('${record.level.name}: ${record.time}: ${record.message}');
    if (record.error != null) {
      debugPrint('Error: ${record.error}');
      debugPrint('Stack trace: ${record.stackTrace}');
    }
  });

  runZonedGuarded(() {
    WidgetsFlutterBinding.ensureInitialized(); // 确保Flutter绑定初始化
    runApp(const App());
  }, (error, stackTrace) {
    Logger('App').severe("未捕获的异常", error, stackTrace);
  });
}

class App extends StatelessWidget {
  const App({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Virtual Fitness Coach',
      theme: ThemeData(
        primarySwatch: Colors.blue,
        visualDensity: VisualDensity.adaptivePlatformDensity,
      ),
      home: const HomeScreen(),
    );
  }
}
